from aiogram import Bot, types
from aiogram.types import InlineKeyboardMarkup

from dc_shop.tg_bot.services.tg_helpers import send_tg_message
from dc_shop.worker.exception_handler import exception_handler


@exception_handler
async def notify_user(
    ctx,
    user_tg_id: int,
    text: str,
    reply_markup: types.ReplyKeyboardMarkup | types.InlineKeyboardMarkup | str | None = None,
) -> None:
    bot: Bot = ctx["bot"]

    if isinstance(reply_markup, str):
        reply_markup = InlineKeyboardMarkup.model_validate_json(reply_markup)

    await send_tg_message(bot, user_tg_id, text, reply_markup=reply_markup)
